#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	int n = 0, m = 0;
	scanf("%d %d", &n, &m);
	int arr1[1001] = { 0 };
	int* p1 = arr1;
	int arr2[1001] = { 0 };
	int* p2 = arr2;
	int i = 0, j = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (j = 0; j < m; j++)
	{
		scanf("%d", &arr2[j]);
	}
	int arr3[2001] = { 0 };
	i = 0;
	while ((*p1 == 0) || (*p2 == 0))
	{
		if (*p1 == 0)
		{
			arr3[i] = *p1;
			p1++;
			i++;
		}
		else
		{
			arr3[i] = *p2;
			p2++;
			i++;
		}
	}
	while (*p1 && *p2)
	{
		if (*p1 <= *p2)
		{
			arr3[i] = *p1;
			p1++;
			i++;
		}
		else
		{
			arr3[i] = *p2;
			p2++;
			i++;
		}
	}
	while (*p1)
	{
		arr3[i] = *p1;
		p1++;
		i++;
	}
	while (*p2)
	{
		arr3[i] = *p2;
		p2++;
		i++;
	}
	for (i = 0; i < (n + m); i++)
	{
		printf("%d ", arr3[i]);
	}

	return 0;
}